<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

	<p:dialog id="createAnotherTempsUnitaireId"
		widgetVar="createAnotherTempsUnitaireWv"
		header="Creation Temps unitaire" modal="false" resizable="true">
		<h:form id="createAnotherTempsUnitaireFormId">

			<h4>Nom de Temps unitaire</h4>
			<h:inputText
				value="#{activiteManagedBean.toBeAddedTempsUnitaire.name}" />
			<table class="nostyle">
				<tr>
					<td width="1"><p:commandButton value="Enregistrer"
							oncomplete="createAnotherTempsUnitaireWv.hide()"
							actionListener="#{activiteManagedBean.saveTempsUnitaire}"
							update=":addOperationFormId:tempsUnitaireDataListId"></p:commandButton></td>
					<td width="232"><p:commandButton
							id="cancelSaveAnotherTempsUnitaireId" value="Annuler"
							oncomplete="createAnotherTempsUnitaireWv.hide()"></p:commandButton></td>
				</tr>
			</table>
		</h:form>
	</p:dialog>


	<p:dialog id="createAnotherQuantiteId"
		widgetVar="createAnotherQuantiteWv" header="Creation Quantite"
		modal="false" resizable="true">
		<h:form id="createAnotherQuantiteFormId">
			<h4>Nom de Quantite</h4>
			<h:inputText value="#{activiteManagedBean.toBeAddedQuantite.name}" />
			<table class="nostyle">
				<tr>
					<td width="1"><p:commandButton value="Enregistrer"
							oncomplete="createAnotherQuantiteWv.hide()"
							actionListener="#{activiteManagedBean.saveQuantite}"
							update=":addOperationFormId:quantite1DataListId :addOperationFormId:quantite2DataListId "></p:commandButton></td>
					<td width="232"><p:commandButton
							id="cancelSaveAnotherQuantiteId" value="Annuler"
							oncomplete="createAnotherQuantiteWv.hide()"></p:commandButton></td>
				</tr>
			</table>
		</h:form>
	</p:dialog>

	<p:dialog id="deleteQuantiteId"
		
		header="Supprimer une quantite" 
		widgetVar="deleteQuantiteWv" width="500">
		<h:form>
			<p:outputPanel id="deleteQuantitePanelId">
			<h:outputLabel value="Vous voulez supprimer cette quantite  #{activiteManagedBean.selectedQuantite1}"></h:outputLabel>
			
			
				<div align="right">
					<p:commandButton value="Annuler"
						oncomplete="deleteQuantiteWv.hide()"  />
					<p:commandButton value="Supprimer"
						oncomplete="deleteQuantiteWv.hide()"
						actionListener="#{activiteManagedBean.deleteQuantite}"
						update=":addOperationFormId:panelGridAddoperationQuantite1ForumleId" />
				</div>
			</p:outputPanel>
		</h:form>
	</p:dialog>









	<p:dialog id="deleteTempsUnitaireId"
		width="500" height="100"
		header="Supprimer un Temps unitaire"  
		widgetVar="deleteTempsUnitaireWv">
		<h:form>
			<p:outputPanel id="deleteTempsUnitairePanelId">
			<h:outputLabel value="Vous voulez supprimer ce Temps Unitaire  #{activiteManagedBean.selectedTempsUnitaire}"></h:outputLabel>
			
				<div align="right">
					<p:commandButton value="Annuler"
						oncomplete="deleteTempsUnitaireWv.hide()"  />
					<p:commandButton value="Supprimer"
						oncomplete="deleteTempsUnitaireWv.hide()"
						actionListener="#{activiteManagedBean.deleteTempsUnitaire}"
						update=":addOperationFormId:panelGridAddoperationTempsUnitaireForumleId" />
				</div>
			</p:outputPanel>
		</h:form>
</p:dialog>


	<h:form id="addOperationFormId">
		 <p:messages id="errorMessages" showDetail="true" autoUpdate="true" closable="true" /> 
		<h1>Activités</h1>
		<h2 class="tit">
			Création de l'Opération
			<p:spacer width="550" height="10" />

		</h2>
		<table class="nostyle" width="400">

			<tr>

				<h4>Nom de l'opération</h4>
				<h:inputText
					value="#{activiteManagedBean.toBeAddedOrEditedOperation.name}" />

			</tr>
			<tr>

				<h4>Numero de l'opération</h4>
				<h:inputText id="addOperationNumberOpe"
					value="#{activiteManagedBean.toBeAddedOrEditedOperation.number}" >
					<f:validateLongRange minimum="0" ></f:validateLongRange>
							<p:ajax event="blur" update="addOperationNumberOpe" />
					</h:inputText>
					<p:message id="msg1" for="addOperationNumberOpe" display="text" />
			</tr>

			<tr>

				<p:outputPanel id="addOperationForumleDeCalculOutputPanelId">
					<h3>Formule de calcul</h3>
					<p:selectOneRadio id="addOperationFormuleDeCalculId"
						layout="pageDirection"
						value="#{activiteManagedBean.selectedOperationForumleDeCalcul}"
						styleClass="nostyle">
						<p:ajax event="change"
							listener="#{activiteManagedBean.onSelectOperationForumleDeCalcul}"
							update="panelGridAddoperationTempsUnitaireForumleId panelGridAddoperationQuantite1ForumleId panelGridAddoperationQuantite2ForumleId,coeffecientPanel" />
						<f:selectItem itemLabel="Temps unitaire" itemValue="1" />
						<br></br>
						<f:selectItem itemLabel="Temps unitaire * quantite" itemValue="2" />
						<br></br>
						<f:selectItem itemLabel="Temps unitaire * quantite*coeffecient"
							itemValue="3" />

						<f:selectItem itemLabel="Temps unitaire * quantite1* quantite2"
							itemValue="4" />
						<br></br>
						<f:selectItem
							itemLabel="Temps unitaire * quantite1* quantite2 * coeffecient"
							itemValue="5" />

						<f:selectItem itemLabel="Temps unitaire * quantite1 / quantite2"
							itemValue="6" />
						<f:selectItem
							itemLabel="Temps unitaire * quantite1/Temps unitaire * coeffecient"
							itemValue="7" />
					</p:selectOneRadio>
				</p:outputPanel>
			</tr>
			<tr>


				<p:panel id="panelGridAddoperationTempsUnitaireForumleId"
					visible="#{activiteManagedBean.visibilitypanelGridAddoperationTempsUnitaireForumleId}">

Temps Unitaire
					<p:selectOneRadio id="tempsUnitaireDataListId"
						layout="pageDirection"
						value="#{activiteManagedBean.selectedTempsUnitaire}">
						<f:selectItems
							value="#{activiteManagedBean.availbleTempsUnitiare}"></f:selectItems>
					</p:selectOneRadio>

					<br></br>
					<br></br>
					<p:commandButton value="Creer un nouveau Temps Unitaire"
						oncomplete="createAnotherTempsUnitaireWv.show()"></p:commandButton>
					<p:commandButton value="Supprimer un  Temps Unitaire"
						oncomplete="deleteTempsUnitaireWv.show()"
						update=":deleteTempsUnitaireId"></p:commandButton>
				</p:panel>
			</tr>
			<tr>
				<p:panel id="panelGridAddoperationQuantite1ForumleId"
					visible="#{activiteManagedBean.visibilitypanelGridAddoperationQuantite1ForumleId}">
					
					Quantite1
					<p:selectOneRadio id="quantite1DataListId" layout="pageDirection"
						value="#{activiteManagedBean.selectedQuantite1}">
						<f:selectItems value="#{activiteManagedBean.availbleQuantite}"></f:selectItems>
					</p:selectOneRadio>

					<br></br>
					<br></br>
					<p:commandButton value="Creer une nouvelle quantite"
						oncomplete="createAnotherQuantiteWv.show()"></p:commandButton>
					<p:commandButton value="Supprimer une quantite"
						oncomplete="deleteQuantiteWv.show()"
						update=":deleteQuantiteId"></p:commandButton>
				</p:panel>
			</tr>
			<tr>
				<br></br>
				<p:panel id="panelGridAddoperationQuantite2ForumleId"
					visible="#{activiteManagedBean.visibilitypanelGridAddoperationQuantite2ForumleId}">
				
                Quantite2
      	<p:selectOneRadio id="quantite2DataListId" layout="pageDirection"
						value="#{activiteManagedBean.selectedQuantite2}">
						<f:selectItems value="#{activiteManagedBean.availbleQuantite}"></f:selectItems>
					</p:selectOneRadio>
						<br></br>
					<br></br>
					<p:commandButton value="Creer une nouvelle quantite"
						oncomplete="createAnotherQuantiteWv.show()"></p:commandButton>
					<p:commandButton value="Supprimer une quantite"
						oncomplete="deleteQuantiteWv.show()"
						update=":deleteQuantiteId"></p:commandButton>
				</p:panel>
			</tr>
			<tr>
				<p:panel id="coeffecientPanel"
					visible="#{activiteManagedBean.visibilityCoeffecient}">
					<div>Saisir un coeffecient</div>
					<h:inputText
						value="#{activiteManagedBean.toBeAddedOrEditedOperation.coeffecientString}">

					</h:inputText>
				</p:panel>
				<br></br>
				<br></br>

				<h:outputLabel value="La magasin peut supprimer l'operation"></h:outputLabel>
				<p:selectOneRadio id="addOperationMagasinCanDeleteOperationId"
					value="#{activiteManagedBean.magasinCanDeleteOperationWa}">
					<f:selectItem itemLabel="Oui" itemValue="1" />
					<f:selectItem itemLabel="Non" itemValue="2" />


				</p:selectOneRadio>
				<br></br>
				<br></br>

			</tr>
			<tr>
				<div align="left">
					<p:commandButton id="addOperationCancelId" value="Annuler"
						oncomplete="addOperation2Wv.hide()" />
					<p:commandButton id="addOperationConfirm12Id" value="Enregistrer"
						oncomplete="addOperation2Wv.hide()"
						actionListener="#{activiteManagedBean.addOperation}"
						update=":activiteFormId:operationDataListId" />
				</div>
			</tr>
		</table>
	</h:form>

</ui:composition>